package com.xxl.conf.core.util;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

/**
 * 读取配置文件类
 * 
 * @author vimesly
 * 
 */
public class SettingUtil {

	/**
	 * 根据properties文件的key获取value
	 * 
	 * @param filePath
	 *            properties文件路径
	 * @param key
	 *            属性key
	 * @return 属性value
	 */
	public static String getProperty(String filePath, String key) {
		Properties props = new Properties();
		// java路劲不知道打包web项目有没有问题。。~~~
		String path = SettingUtil.class.getResource("/").getPath();
		try {
			InputStream in = new BufferedInputStream(new FileInputStream(path
					+ filePath));
			props.load(in);
			String value = props.getProperty(key);
			return value;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

}
